package org.tulkas.http;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class CacheMap<K, V> extends LinkedHashMap<K, V> {
	private static final long serialVersionUID = 8383471751965327155L;

	private final int maxEntries;

	CacheMap(int maxEntries) {
		super(20, 0.75f, true);
		this.maxEntries = maxEntries;
	}

	@Override
	protected boolean removeEldestEntry(final Map.Entry<K, V> eldest) {
		return size() > this.maxEntries;
	}
}
